﻿using Caliburn.Micro;
using KouDai.Phone.Helper;
using KouDai.Phone.Models;
using KouDai.Phone.Utils;
using System.Collections.Generic;
using System.Collections.ObjectModel;

namespace KouDai.Phone.ViewModels
{
    public class DemoPageViewModel : KouDaiScreen
    {
        #region Fields
        private readonly INavigationService _navigationService;
        private ObservableCollection<HoneyEntity> _honeyItems = new ObservableCollection<HoneyEntity>();
        #endregion

        #region Constructor
        public DemoPageViewModel()
        {
            if (Execute.InDesignMode)
            {
                LoadDesignData();
            }
        }

        public DemoPageViewModel(INavigationService navigationService)
        {
            _navigationService = navigationService;
        }
        #endregion


        #region Properties
        public ObservableCollection<HoneyEntity> HoneyItems
        {
            get { return _honeyItems; }
            set
            {
                if (value != _honeyItems)
                {
                    _honeyItems = value;
                    this.NotifyOfPropertyChange(() => this.HoneyItems);
                }
            }
        }
        #endregion

        #region override
        public override void LoadDesignData()
        {
            List<HoneyEntity> honeyList = new List<HoneyEntity>();
            for (int i = 0; i < 10; i++)
            {
                honeyList.Add(new HoneyEntity { ImageUrlForIphone = "http://img.geilicdn.com/taobao18553835260_146x146.jpg", Name = "2013新款韩版甜美淑女毛毛包夹子包毛绒绒手拿斜挎单肩女包包" });
            }
            honeyList.ToObservableCollection(HoneyItems);
        }

        protected override void OnInitialize()
        {
            //string json = StorageHelper.ReadFileFromLocalJson("HoneyItems.json");
            //List<HoneyEntity> honeyList = new List<HoneyEntity>();
            //new HoneyParser().ParseJson(json, honeyList);
            //honeyList.ToObservableCollection(HoneyItems);
        }

        #endregion
    }
}
